----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 21120 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 240
SPELL.m_sName = "Shield Slam"
SPELL.m_sToolTip = [[You strike the target
					with your current weapon,
					which alters the effect.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/shield_slam.png"
SPELL.m_bRequiresTarget = true
SPELL.m_iManaCost = 0
SPELL.m_iCoolDown = 2.5
SPELL.m_iSpellType = SPELLTYPE_MAA
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

local range = 100

function SPELL:Cast( pl, target )
	
	if(target && target:IsValid() && target != pl ) then
		if(pl:IsPlayer())then
			pl:DoAnimationEvent(ACT_GMOD_GESTURE_MELEE_SHOVE_2HAND)
		else
			pl:RestartGesture(ACT_GMOD_GESTURE_MELEE_SHOVE_2HAND)
		end
		pl:EmitSound("devin/blackbetty/weapons/swing/2h_"..math.random(1,3)..".wav", 100, 100+math.random(-10,-35))
			timer.Simple(0.35, function()
				if(target and pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
					self:Effect(pl, target)
					--self:ApplySpellMods(self, pl, target)
				end
			end)
		timer.Simple(0.35, function()
				pl.InSpellAnimation = false
				pl:SetNWBool("Casting", false)
				pl:SetNWBool("Casted", false)
		end)
		
	end
end

function SPELL:Effect(pl, target)

	local weapon = nil
	if(pl:IsPlayer())then
		weapon = pl:GetWeapon("weapon_all")
	end
	target:EmitSound("devin/blackbetty/weapons/2HMaceHitPlateCrit.wav", 150, 100+math.random(-10,-30))
	ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
	if(SERVER)then
		target:SetVelocity(((pl:GetPos()- Vector(0, 0, 40)) - target:GetPos())*-3.25)
		if(weapon)then
			self:DealDamage(weapon.MinWeaponDamage*1.5, weapon.MaxWeaponDamage*1.5, pl, target, DMG_GENERIC)
		else
			self:DealDamage(pl.MinDamage*3, pl.MaxDamage*3, pl, target, DMG_GENERIC)
		end
	end
end



